package cn.edu.scau.cmi.ema.service.base;

import cn.edu.scau.cmi.ema.base.CmiController;
import cn.edu.scau.cmi.ema.domain.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

@Service()
@Transactional(timeout=300000000)
public class EntityFactoryServiceImpl extends CmiController implements EntityFactoryService{
	public EntityFactoryServiceImpl() {

	}
	@Override
	public Object initObject(String entityName) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
		Class<?> cla = Class.forName(entityName);
		Object entity = cla.getConstructor().newInstance();
		// 是否需要考虑父类的fields呢？
		Field[] fields = cla.getDeclaredFields();

		for (Field field : fields) {
			field.setAccessible(true);
			String fieldName = field.getName();

			if (fieldName.equals("$change") || fieldName.equals("serialVersionUID") || fieldName.equals("itemViewType"))
				continue;

			/*fieldName的值是如下的几个基本情况，因此，需要根据不同的情况来获取真正的属性的类型
			 * serialVersionUID不管，field.getGenericType()的结果是以下几个：
			 * class java.util.Calendar class java.lang.Boolean class
			 * cn.edu.scau.cmi.ema.domain.Address class cn.edu.scau.cmi.ema.domain.Address
			 *
			 * java.util.Set<cn.edu.scau.cmi.ema.domain.Event>
			 */

//            如果是Set类型，
			String fieleClassName = field.getGenericType().toString().split(" ")[field.getGenericType().toString().split(" ").length - 1];

			if (fieleClassName.contains("java.util.Set")) {
				fieleClassName = "java.util.Set";
			}

			System.out.println("修正了多余字符串后的type名称是: " + fieleClassName);
//          载入域的对应的类型的类

			Class<?> fieldClass = Class.forName(fieleClassName);
			// 设置器的名称
			String fieldSetMethodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
			Method method = cla.getDeclaredMethod(fieldSetMethodName, fieldClass);

//			根据域的类型，给域不同的初始值，调用设置器赋值
			Object value = null;

			if (fieleClassName.contains("java.util.Calendar")) {
				value = Calendar.getInstance();
			} else if (fieleClassName.contains("java.lang.Boolean")) {
				value = false;
			} else if (fieleClassName.contains("java.lang.Integer")) {
				value = 0;
			} else if (fieleClassName.contains("java.util.Set")) {
				value = new HashSet<Object>();
			} else if (fieleClassName.contains("java.lang.String")) {
				value = " ";
			} else if (fieleClassName.contains("java.math.BigDecimal")) {
				value = new BigDecimal(0);
			}
			else {
				Class<?> entityFieldClass = Class.forName(fieleClassName);
				value = entityFieldClass.getConstructor().newInstance();
			}

//			System.out.println(field.getName() + ": " + value);
			method.invoke(entity, value);
		}

		return entity;
	}

	//	创建一个初始化的event对象，该对象封装了必要的属性，获取该对象后，在业务层修改该事件，减少了代码的冗余部分。
	public Event initEvent() {
		Event event = new Event();

		Set<Adultertype> adultertypesForEvent = new HashSet<Adultertype>();

		event.setAdultertypesForEvent(adultertypesForEvent);
		User auditor = userDAO.findUserById(-2);
		event.setAuditor(auditor);

		Calendar auditTime = Calendar.getInstance();
		event.setAuditTime(auditTime);

		Calendar crawlTime = Calendar.getInstance();
		event.setCrawlTime(null);

		event.setDescription("");

		event.setDiscoveryAddress(addressDAO.findAddressById(-2));

		Set<Eventadulterlink> eventadulterlinksForEvent  = new HashSet<Eventadulterlink>();
		event.setEventadulterlinksForEvent(eventadulterlinksForEvent);

		Set<Eventpunish> eventpunishsForEvent  = new HashSet<Eventpunish>();
		event.setEventpunishsForEvent(eventpunishsForEvent);

		Set<Eventqualitytype> eventqualitytypesForEvent  = new HashSet<Eventqualitytype>();
		event.setEventqualitytypesForEvent(eventqualitytypesForEvent);

		Set<Eventquantitytype> eventquantitytypesForEvent  = new HashSet<Eventquantitytype>();
		event.setEventquantitytypesForEvent(eventquantitytypesForEvent);

		Set<Event> eventsForParent  = new HashSet<Event>();
		event.setEventsForParent(eventsForParent);
		event.setFoodbatch(foodbatchDAO.findFoodbatchById(-2));

		Set<Motive> motivesForEvent = new HashSet<Motive>();
		event.setMotivesForEvent(motivesForEvent);

		event.setName("");
		event.setParent(eventDAO.findEventById(-2));

		Set<Picture> picturesForEvent  = new HashSet<Picture>();
		event.setPicturesForEvent(picturesForEvent);

		event.setReportor( userDAO.findUserById(-2));

		event.setSourceAddress(addressDAO.findAddressById(-2));
		event.setSourceTime(Calendar.getInstance());
		event.setStatus(false);

		event.setSubject(subjectDAO.findSubjectById(-2) );
		event.setUrl(urlDAO.findUrlById(-2));

		Set<Video> videosForEvent  = new HashSet<Video>();
		event.setVideosForEvent(videosForEvent);
		return event;
	}

	public Food initFood() {
		Food food = new Food();
		food.setBrand(brandDAO.findBrandById(-2));
		food.setDescription("");

		Set<Detectstandard> detectstandardsForFood = new HashSet<Detectstandard>();
		food.setDetectstandardsForFood(detectstandardsForFood);
		food.setExpire(expireDAO.findExpireById(-2));

		food.setProductcode(productcodeDAO.findProductcodeById(-2));

		Set<Foodadditive> foodadditivesForFood = new HashSet<Foodadditive>();
		food.setFoodadditivesForFood(foodadditivesForFood);

		Set<Foodbatch> foodbatchsForFood = new HashSet<Foodbatch>();
		food.setFoodbatchsForFood(foodbatchsForFood);

		Set<Foodmaterial> foodmaterialsForFood = new HashSet<Foodmaterial>() ;
		food.setFoodmaterialsForFood(foodmaterialsForFood);

		Set<Foodsaleaddress> foodsaleaddresssForFood = new HashSet<Foodsaleaddress>();
		food.setFoodsaleaddresssForFood(foodsaleaddresssForFood );

		food.setFoodtype(foodtypeDAO.findFoodtypeById(-2));
		food.setName("");
		Set<Packingmethod> packingmethodsForFood = new HashSet<Packingmethod>();
		food.setPackingmethodsForFood(packingmethodsForFood);
		Set<Picture> picturesForFood = new HashSet<Picture>();;
		food.setPicturesForFood(picturesForFood);
		Set<Processmethod> processmethodsForFood = new HashSet<Processmethod>();;
		food.setProcessmethodsForFood(processmethodsForFood);
		food.setProducer(producerDAO.findProducerById(-2));
		food.setProductcode(productcodeDAO.findProductcodeById(-2));
		food.setStoremethod(storemethodDAO.findStoremethodById(-2));
		food.setTaste(tasteDAO.findTasteById(-2));
		Set<Video> videosForFood = new HashSet<Video>();;
		food.setVideosForFood(videosForFood);

		return food ;

	}


	public Foodbatch initBatch() {
		Foodbatch foodbatch = new Foodbatch();
		foodbatch.setBatch("");
		Calendar date = Calendar.getInstance();
		date.setTimeInMillis(-28800000);
		foodbatch.setDate(date );
		foodbatch.setDescription("");
		Set<Detect> detectsForFoodbatch = new HashSet<Detect>();
		foodbatch.setDetectsForFoodbatch(detectsForFoodbatch);
		Set<Event> eventsForFoodbatch = new HashSet<Event>();
		foodbatch.setEventsForFoodbatch(eventsForFoodbatch);
		foodbatch.setFood(foodDAO.findFoodById(-2));
		Set<Foodbatchadditive> foodbatchadditivesForFoodbatch = new HashSet<Foodbatchadditive>();
		foodbatch.setFoodbatchadditivesForFoodbatch(foodbatchadditivesForFoodbatch);
		Set<Foodbatchfiller> foodbatchfillersForFoodbatch = new HashSet<Foodbatchfiller>();
		foodbatch.setFoodbatchfillersForFoodbatch(foodbatchfillersForFoodbatch);
		Set<Foodbatchmaterial> foodbatchmaterialsForFoodbatch = new HashSet<Foodbatchmaterial>();
		foodbatch.setFoodbatchmaterialsForFoodbatch(foodbatchmaterialsForFoodbatch);
		foodbatch.setName("");
		BigDecimal price = BigDecimal.ZERO;
		foodbatch.setPrice(price);
		foodbatch.setUnit(unitDAO.findUnitById(-2));



		return foodbatch;
	}

	public Filler initFiller() {
		Filler filler = new Filler();
		filler.setDescription("");
		Set<Fillerfiller> fillerfillersForOther = new HashSet<Fillerfiller>();
		filler.setFillerfillersForOther(fillerfillersForOther);
		Set<Fillerfiller> fillerfillersForSelf = new HashSet<Fillerfiller>();
		filler.setFillerfillersForSelf(fillerfillersForSelf);
		Set<Fillerhazard> fillerhazardsForFiller = new HashSet<Fillerhazard>();
		filler.setFillerhazardsForFiller(fillerhazardsForFiller);
		filler.setFillertype(fillertypeDAO.findFillertypeById(-2));
		Set<Foodbatchfiller> foodbatchfillersForFiller = new HashSet<Foodbatchfiller>();
		filler.setFoodbatchfillersForFiller(foodbatchfillersForFiller);
		filler.setName("");
		return filler;
	}

	public Hazard initHazard() {
		Hazard hazard = new Hazard();
		hazard.setDescription("");
		Set<Fillerhazard> fillerhazardsForHazard = new HashSet<Fillerhazard>();
		hazard.setFillerhazardsForHazard(fillerhazardsForHazard);
		Set<Fillertype> fillertypesForHazard = new HashSet<Fillertype>();
		hazard.setFillertypesForHazard(fillertypesForHazard);
		hazard.setName("");
		return hazard;
	}

	public Fillertype initFillertype() {
		Fillertype fillertype= new Fillertype();
		fillertype.setDescription("");
		Set<Filler> fillersForFillertype = new HashSet<Filler>();
		fillertype.setFillersForFillertype(fillersForFillertype);
		Set<Hazard> hazardsForFillertype= new HashSet<Hazard>();
		fillertype.setHazardsForFillertype(hazardsForFillertype);
		fillertype.setName("");
		fillertype.setParent(fillertypeDAO.findFillertypeById(-2).getId());
		return fillertype;
	}

	public Foodbatchfiller initFoodbatchfiller() {
		Foodbatchfiller foodbatchfiller = new Foodbatchfiller();
		foodbatchfiller.setDescription("");
		foodbatchfiller.setFiller(fillerDAO.findFillerById(-2));
		foodbatchfiller.setFoodbatch(foodbatchDAO.findFoodbatchById(-2));
		foodbatchfiller.setName("");
		BigDecimal quantity = BigDecimal.ZERO;
		foodbatchfiller.setQuantity(quantity);
		foodbatchfiller.setUnit(unitDAO.findUnitById(-2));
		return foodbatchfiller;
	}

	public Feature initFeature() {
		Feature feature = new Feature();
		feature.setDescription("");
		Set<Detectdetail> detectdetailsForFeature = new HashSet<Detectdetail>();
		feature.setDetectdetailsForFeature(detectdetailsForFeature);
		Set<Detectfeature> detectfeaturesForFeature = new HashSet<Detectfeature>();
		feature.setDetectfeaturesForFeature(detectfeaturesForFeature);
		feature.setDetectmethod(detectmethodDAO.findDetectmethodById(-2));
		Set<Detectstandard> detectstandardsForFeature = new HashSet<Detectstandard>();
		feature.setDetectstandardsForFeature(detectstandardsForFeature);
		Set<Featurestandard> featurestandardsForFeature = new HashSet<Featurestandard>();
		feature.setFeaturestandardsForFeature(featurestandardsForFeature);
		feature.setName("");
		return feature;
	}

	public Detectstandard initDetectstandard() {
		Detectstandard detectstandard = new Detectstandard();
		Calendar date = Calendar.getInstance();
		date.setTimeInMillis(-28800000);
		detectstandard.setDate(date );
		detectstandard.setDescription("");
		detectstandard.setFeature(featureDAO.findFeatureById(-2));
		detectstandard.setFood(foodDAO.findFoodById(-2));
		BigDecimal max = BigDecimal.ZERO;;
		detectstandard.setMax(max);
		BigDecimal min= BigDecimal.ZERO;;
		detectstandard.setMin(min);
		detectstandard.setName("");
		detectstandard.setUnit(unitDAO.findUnitById(-2));
		return detectstandard;
	}


	@Override
	public Url initUri() {
		Url uri = new Url();
		uri.setAuthor(userDAO.findUserById(-2));
		uri.setContent("");
		Calendar date = Calendar.getInstance();
		uri.setDate(date);
		uri.setDescription("");
		Set<Event> eventsForUri = new HashSet<Event>();
		uri.setEventsForUrl(eventsForUri );
		uri.setName("");
		uri.setSite(siteDAO.findSiteById(-2));
		uri.setTitle("");
		uri.setValue("");
		return uri;
	}


	@Override
	public Subject initSubject() {
		Subject subject = new Subject();
		subject.setDescription("");
		Set<Event> eventsForSubject = new HashSet<Event>();
		subject.setEventsForSubject(eventsForSubject );
		subject.setName("");
		return subject;
	}


	@Override
	public Eventadulterlink initEventadulterlink() {
		Eventadulterlink eventadulterlink = new Eventadulterlink();
		eventadulterlink.setAdulterlink(adulterlinkDAO.findAdulterlinkById(-2));
		eventadulterlink.setDescription("");
		eventadulterlink.setEvent(eventDAO.findEventById(-2));
		eventadulterlink.setName("");
		return eventadulterlink;
	}


	@Override
	public Detectdetail initDetectdetail() {
		Detectdetail detectdetail = new Detectdetail();
		detectdetail.setDescription("");
		detectdetail.setDetect(detectDAO.findDetectById(-2));
		detectdetail.setFeature(featureDAO.findFeatureById(-2));
		detectdetail.setName("");
		detectdetail.setUnit(unitDAO.findUnitById(-2));
		detectdetail.setValue("");
		return detectdetail;
	}


	@Override
	public Detect initDetect() {
		Detect detect = new Detect();
		detect.setConclusion("");
		detect.setDate(Calendar.getInstance());
		detect.setDescription("");
		detect.setDetectdepartment(detectdepartmentDAO.findDetectdepartmentById(-2));
		Set<Detectdetail> detectdetailsForDetect = new HashSet<Detectdetail>();
		detect.setDetectdetailsForDetect(detectdetailsForDetect);
		Set<Detectfeature> detectfeaturesForDetect = new HashSet<Detectfeature>();
		detect.setDetectfeaturesForDetect(detectfeaturesForDetect);
		detect.setFoodbatch(foodbatchDAO.findFoodbatchById(-2));
		detect.setName("");
		detect.setDetector(userDAO.findUserById(-2));

		return detect;
	}


	@Override
	public Adulterlink initAdulterlink() {
		Adulterlink adulterlink = new Adulterlink();
		adulterlink.setDescription("");
		Set<Eventadulterlink> eventadulterlinksForAdulterlink = new HashSet<Eventadulterlink>();
		adulterlink.setEventadulterlinksForAdulterlink(eventadulterlinksForAdulterlink );
		adulterlink.setName("");
		return adulterlink;
	}
	@Override
	public Detectdepartment initDetectdepartment() {
		Detectdepartment detectdepartment = new Detectdepartment();
		detectdepartment.setDescription("");
		detectdepartment.setDetectsForDetectdepartment(new HashSet<Detect>());
		detectdepartment.setUsersForDetectdepartment(new HashSet<User>());
		detectdepartment.setAddress(addressDAO.findAddressById(-2));
		return detectdepartment;
	}
	@Override
	public Foodtype initFoodtype() {
		Foodtype foodtype = new Foodtype();
		foodtype.setDescription("");
		foodtype.setFoodsForFoodtype(new HashSet<Food>());
		foodtype.setFoodtypesForParent(new HashSet<Foodtype>());
		foodtype.setName("");
		foodtype.setParent(null);
		foodtype.setStandardsForFoodtype(new HashSet<Standard>());

		return foodtype;
	}
	@Override
	public Foodbatch initFoodbatch() {
		Foodbatch foodbatch = new Foodbatch();
		foodbatch.setBatch("");
		Calendar data = Calendar.getInstance();
		data.set(0, 0, 0, 0, 0, 0);
		//		指定1970.0.1的日期
		foodbatch.setDate(data);
		foodbatch.setDescription("");
		foodbatch.setDetectsForFoodbatch(new HashSet<Detect>());
		foodbatch.setEventsForFoodbatch(new HashSet<Event>());
		foodbatch.setFood(foodDAO.findFoodById(-2));
		foodbatch.setFoodbatchadditivesForFoodbatch(new HashSet<Foodbatchadditive>());
		foodbatch.setFoodbatchfillersForFoodbatch(new HashSet<Foodbatchfiller>());
		foodbatch.setFoodbatchmaterialsForFoodbatch(new HashSet<Foodbatchmaterial>());
		foodbatch.setName("");
		BigDecimal price = new BigDecimal(0);
		foodbatch.setPrice(price );
		foodbatch.setUnit(unitDAO.findUnitById(-2));

		return foodbatch;
	}
	@Override
	public Brand initBrand() {
		Brand brand = new Brand();
		brand.setDescription("");
		brand.setFoodsForBrand(new HashSet<Food>());
		brand.setName("");
		return brand;
	}
	@Override
	public Producer initProducer() {
		Producer producer = new Producer();
		producer.setName("");
		producer.setAddress(addressDAO.findAddressById(-2));
		producer.setDescription("");
		producer.setFoodsForProducer(new HashSet<Food>());
		producer.setLicense("");
		producer.setPurchaseadditivesForProducer(new HashSet<Purchaseadditive>());
		producer.setPurchasematerialsForProducer(new HashSet<Purchasematerial>());
		return producer;
	}
	@Override
	public Featurestandard initFeaturestandard() {
		Featurestandard featurestandard = new Featurestandard();
		featurestandard.setDescription("");
		featurestandard.setFeature(featureDAO.findFeatureById(-2));
		BigDecimal max = new BigDecimal(0);
		featurestandard.setMax(max);
		BigDecimal min = new BigDecimal(0);
		featurestandard.setMin(min);
		featurestandard.setName("");
		featurestandard.setStandard(standardDAO.findStandardById(-2));
		featurestandard.setUnit(unitDAO.findUnitById(-2));
		return featurestandard;
	}
	@Override
	public Detectfeature initDetectfeature() {
		Detectfeature detectfeature = new Detectfeature();
		detectfeature.setDescription("");
		detectfeature.setDetect(detectDAO.findDetectById(-2));
		detectfeature.setFeature(featureDAO.findFeatureById(-2));
		detectfeature.setName("");
		detectfeature.setQuantity(new BigDecimal(0));
		detectfeature.setUnit(unitDAO.findUnitById(-2));
		return detectfeature;
	}
	@Override
	public Packingmethod initPackingmethod() {
		Packingmethod packingmethod = new Packingmethod();
		packingmethod.setDescription("");
		packingmethod.setFee(new BigDecimal(0));
		packingmethod.setName("");
		packingmethod.setUnit(unitDAO.findUnitById(-2));
		return packingmethod;
	}
	@Override
	public Crawlerdetect initCrawlerdetect() {
		Crawlerdetect crawlerdetect = new Crawlerdetect();
		crawlerdetect.setBrand(null);
		crawlerdetect.setDescription(null);
		crawlerdetect.setDetectannounce(null);
		crawlerdetect.setDetectannouncedate(null);
		crawlerdetect.setDetectasksource(null);
		crawlerdetect.setDetectdate(null);
		crawlerdetect.setDetectdepartment(null);
		crawlerdetect.setDetectdescription(null);
		crawlerdetect.setDetectfeature(null);
		crawlerdetect.setDetectlink(null);
		crawlerdetect.setDetectnumber(null);
		crawlerdetect.setDetectproject(null);
		crawlerdetect.setDetectresult(null);
		crawlerdetect.setDetectstandard(null);
		crawlerdetect.setDetectstandardvalue(null);
		crawlerdetect.setDisagreeapply(null);
		crawlerdetect.setDisagreeconclusion(null);
		crawlerdetect.setDisagreecontent(null);
		crawlerdetect.setDisagreedate(null);
		crawlerdetect.setFilename(null);
		crawlerdetect.setFood(null);
		crawlerdetect.setFoodbatch(null);
		crawlerdetect.setFoodtype(null);
		crawlerdetect.setCrawlerdetectstatus(null);
		crawlerdetect.setIsredetectapply(null);
		crawlerdetect.setMaxcolumn(null);
		crawlerdetect.setMiscellaneous(null);
		crawlerdetect.setName(null);
		crawlerdetect.setNetplatform(null);
		crawlerdetect.setNumber(null);
		crawlerdetect.setPackagemethod(null);
		crawlerdetect.setProducedate(null);
		crawlerdetect.setProducer(null);
		crawlerdetect.setProduceraddress(null);
		crawlerdetect.setPurchasedate(null);
		crawlerdetect.setRedetectapplier(null);
		crawlerdetect.setRedetectresult(null);
		crawlerdetect.setRownumber(null);
		crawlerdetect.setSubject(null);
		crawlerdetect.setSubjectaddress(null);

		return crawlerdetect;
	}
	@Override
	public Crawlerevent initCrawlerevent() {
		Crawlerevent crawlerevent = new Crawlerevent();
		crawlerevent.setBrand(null);
		crawlerevent.setDescription(null);
		crawlerevent.setDetectannounce(null);
		crawlerevent.setDetectannouncedate(null);
		crawlerevent.setDetectasksource(null);
		crawlerevent.setDetectdate(null);
		crawlerevent.setDetectdepartment(null);
		crawlerevent.setDetectdescription(null);
		crawlerevent.setDetectfeature(null);
		crawlerevent.setDetectlink(null);
		crawlerevent.setDetectnumber(null);
		crawlerevent.setDetectproject(null);
		crawlerevent.setDetectresult(null);
		crawlerevent.setDetectstandard(null);
		crawlerevent.setDetectstandardvalue(null);
		crawlerevent.setDisagreeapply(null);
		crawlerevent.setDisagreeconclusion(null);
		crawlerevent.setDisagreecontent(null);
		crawlerevent.setDisagreedate(null);
		crawlerevent.setFilename(null);
		crawlerevent.setFood(null);
		crawlerevent.setFoodbatch(null);
		crawlerevent.setFoodtype(null);
		crawlerevent.setCrawlerdetectstatus(null);
		crawlerevent.setIsredetectapply(null);
		crawlerevent.setMaxcolumn(null);
		crawlerevent.setMiscellaneous(null);
		crawlerevent.setName(null);
		crawlerevent.setNetplatform(null);
		crawlerevent.setNumber(null);
		crawlerevent.setPackagemethod(null);
		crawlerevent.setProducedate(null);
		crawlerevent.setProducer(null);
		crawlerevent.setProduceraddress(null);
		crawlerevent.setPurchasedate(null);
		crawlerevent.setRedetectapplier(null);
		crawlerevent.setRedetectresult(null);
		crawlerevent.setRownumber(null);
		crawlerevent.setSubject(null);
		crawlerevent.setSubjectaddress(null);

		return crawlerevent;
	}

	@Override
	public Eventpunish initEventpunish() {
		Eventpunish eventpunish = new Eventpunish();
		eventpunish.setDate(null);
		eventpunish.setDescription(null);
		eventpunish.setEvent(eventDAO.findEventById(-2));
		eventpunish.setName(null);
		eventpunish.setPunish(punishDAO.findPunishById(-2));
		return eventpunish;
	}

	@Override
	public Adultertype initAdultertype() {
		Adultertype adultertype = new Adultertype();
		adultertype.setDescription(null);
		adultertype.setEventsForAdultertype(null);
		adultertype.setName(null);
		return adultertype;
	}
	@Override
	public Discoverylink initDiscoverylink() {
		Discoverylink discoverylink = new Discoverylink();
		discoverylink.setDescription(null);

		discoverylink.setName(daoPackageName);

		return discoverylink;
	}
	@Override
	public Detectmethod initDetectmethod() {
		Detectmethod detectmethod = new Detectmethod();
		detectmethod.setDescription(null);
		detectmethod.setDetectdetailsForDetectmethod(null);
		detectmethod.setFeaturesForDetectmethod(null);
		detectmethod.setName(null);
		detectmethod.setStep(null);
		return detectmethod;
	}
	@Override
	public Law initLaw() {
		Law law = new Law();
		law.setDescription(null);
		law.setEventsForLaw(null);
		law.setName(null);
		return law;
	}
	@Override
	public User initUser() {
		User user = new User();
		user.setAuthoritysForUser(null);
		user.setBirthday(null);
		user.setCareer(null);
		user.setCellphone(null);
		user.setDescription(null);
		user.setDetectdepartmentsForUser(null);
		user.setDetectsForDetector(null);
		return user;
	}
	@Override
	public Eventhazard iniEventhazard() {
		Eventhazard eventhazard = new Eventhazard();
		eventhazard.setDescription(null);
		eventhazard.setEvent(null);
		eventhazard.setHazard(null);

		return eventhazard;
	}
}
